class test {
    private int[] dates = new int[Integer.MAX_VALUE];

    private int head = 0;

    private int tail = 0;

    private int size = 0;

    public test() {

    }

    public test(int p) {
        dates = new int[p];
    }


    public void put(int p) {
        if (size >= dates.length) {

            return;
        }

        dates[tail] = p;
        tail++;
        if (tail >= dates.length) {
            tail = 0;
        }
        size++;
    }

    public int take() {
        if (size == 0) {
            return -1;
        }
        int p = dates[head];
        head++;
        if (head >= dates.length) {
            head = 0;
        }
        size--;
        return p;
    }
}

public class Demo4 {

    public static void main(String[] args) {

        test t = new test(100);

    }

}
